package org.jheuristics.ga.operators.closures;

import org.jheuristics.ga.GAConfig;
import org.jheuristics.ga.GAStatus;
import org.jheuristics.ga.Population;
import org.jheuristics.ga.operators.ClosureSelection;

public class QuaseSetSelectionClosure implements ClosureSelection {

	/**
	 * TODO
	 *
	 * @param selected
	 * @param population
	 * @param status
	 * @param config
	 * @see org.jheuristics.ga.operators.ClosureSelection#execute(org.jheuristics.ga.Population, org.jheuristics.ga.Population, org.jheuristics.ga.GAStatus, org.jheuristics.ga.GAConfig)
	 */
	public void execute(Population selected, Population population, GAStatus status, GAConfig config) {
		//population = NDV
		//selected = Minimos globais
		
		//Remove os selected.size ultimos elementos da populacao, e adiciona todos os selected
		
		for (int i = 0; i < selected.size(); i++) {
			population.removeIndividual(population.size()-1);
		}
		
//		List<Individual> paraRemover = new LinkedList<Individual>();
//		
//		for (Individual individual : selected.toIndividualArray()) {
//			if(population.contains(individual)) {
//				paraRemover.add(individual);
//			}
//		}
		
//		SPLogger.getInstancia().log(SPLogger.OTIMIZACAO, SPLogger.DEBUG, "paraRemover.size(): "+paraRemover.size());
//		SPLogger.getInstancia().log(SPLogger.OTIMIZACAO, SPLogger.DEBUG, "paraRemover: "+paraRemover);
		
//		selected.removeAll(paraRemover);
		
//		for (Individual ind : population.toIndividualArray()) {
//			selected.removeIndividual(ind);
//		}
		
		
	}

}
